package cn.iocoder.yudao.module.fengdong.smartelderly.dal.mysql.reserved;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.fengdong.smartelderly.dal.dataobject.reserved.ReservedDO;
import cn.iocoder.yudao.module.fengdong.smartelderly.utils.vo.ActivityRecordBaseVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin.reserved.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 预约管理 Mapper
 *
 * @author 沣东养老院管理员
 */
@Mapper
public interface ReservedMapper extends BaseMapperX<ReservedDO> {

    default PageResult<ReservedDO> selectPage(ReservedPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ReservedDO>()
                .eqIfPresent(ReservedDO::getOldmanIdentityCard, reqVO.getOldmanIdentityCard())
                .eqIfPresent(ReservedDO::getPhone, reqVO.getPhone())
                .eqIfPresent(ReservedDO::getOldmanId, reqVO.getOldmanId())
                .eqIfPresent(ReservedDO::getIdentityCard, reqVO.getIdentityCard())
                .eqIfPresent(ReservedDO::getDuration, reqVO.getDuration())
                .eqIfPresent(ReservedDO::getFloorRoom, reqVO.getFloorRoom())
                .eqIfPresent(ReservedDO::getRoomId, reqVO.getRoomId())
                .betweenIfPresent(ReservedDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ReservedDO::getSchedule, reqVO.getSchedules())
                .betweenIfPresent(ReservedDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ReservedDO::getDetails, reqVO.getDetails())
                .eqIfPresent(ReservedDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(ReservedDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ReservedDO::getType, reqVO.getType())
                .likeIfPresent(ReservedDO::getName, reqVO.getName())
                .likeIfPresent(ReservedDO::getOldmanName, reqVO.getOldmanName())
                .eqIfPresent(ReservedDO::getSchedule, reqVO.getSchedule())
                .orderByDesc(ReservedDO::getId));
    }

    default List<ReservedDO> selectList(ReservedExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ReservedDO>()
                .eqIfPresent(ReservedDO::getOldmanIdentityCard, reqVO.getOldmanIdentityCard())
                .eqIfPresent(ReservedDO::getPhone, reqVO.getPhone())
                .eqIfPresent(ReservedDO::getOldmanId, reqVO.getOldmanId())
                .eqIfPresent(ReservedDO::getFloorRoom, reqVO.getFloorRoom())
                .eqIfPresent(ReservedDO::getDuration, reqVO.getDuration())
                .eqIfPresent(ReservedDO::getRoomId, reqVO.getRoomId())
                .eqIfPresent(ReservedDO::getIdentityCard, reqVO.getIdentityCard())
                .betweenIfPresent(ReservedDO::getStartTime, reqVO.getStartTime())
                .betweenIfPresent(ReservedDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(ReservedDO::getDetails, reqVO.getDetails())
                .eqIfPresent(ReservedDO::getOthers, reqVO.getOthers())
                .betweenIfPresent(ReservedDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ReservedDO::getType, reqVO.getType())
                .likeIfPresent(ReservedDO::getName, reqVO.getName())
                .likeIfPresent(ReservedDO::getOldmanName, reqVO.getOldmanName())
                .eqIfPresent(ReservedDO::getSchedule, reqVO.getSchedule())
                .orderByDesc(ReservedDO::getId));
    }

    List<ReservedDO> selectUserExBytype(@Param("param") ActivityRecordBaseVO recordBaseVO);

    IPage<ReservedAppRespVO> getAPPReservedPage(Page<Object> objectPage,@Param("param") ReservedAppPageReqVO pageVO,@Param("userId") Long loginUserId);

    Long selectCountByTenMinute(@Param("type") Integer type,@Param("userId") Long userId);

    IPage<ReservedAppRespVO> getAPPReservedAllPage(Page<Object> objectPage,@Param("param") ReservedAppPageReqVO pageVO,@Param("userId") Long loginUserId);
}
